//
//  WBHomeViewController.swift
//  SinaApp
//
//  Created by shui on 2018/3/22.
//  Copyright © 2018年 shui. All rights reserved.
//

import UIKit

/// 定义全局常量,尽量使用 private 修饰,否则任何地方都可以访问

private let cellID  = "cellID"

class WBHomeViewController: WBBaseViewController {
    
    
    /// 微博数据数组
    private lazy var statusList = [String]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    /// 加载数据
    override func initData() {
        
        for i in 0..<10 {
            statusList.insert(i.description, at: 0)
        }
        
    }
    
    @objc private func showFriends(){
        let vc = WBDemoViewController()
        navigationController?.pushViewController(vc, animated: true)
    }
}

// MARK: - 表格数据源方法,具体的数据源方法,不需要 super
extension WBHomeViewController{
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return statusList.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        //1. 取 cell
         let cell = tableView.dequeueReusableCell(withIdentifier: cellID, for: indexPath)
        //2.设置 cell
        cell.textLabel?.text = statusList[indexPath.row]
        //3. 返回 cell
        return cell
    }
}


// MARK: - 设置界面
extension WBHomeViewController{
    override func initUI() {
        super.initUI()
        
        //设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "好友" ,target: self, action: #selector(showFriends))
        
        //注册原型 cell
        mainTableView?.register(UITableViewCell.self, forCellReuseIdentifier: cellID)
        
    }
    
}











